package com.yourwork.dao.imp;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Repository;

import com.yourwork.common.jpa.StaffManagementRepositoey;
import com.yourwork.dao.StaffManagementDao;
import com.yourwork.model.StaffManagement;
@Repository(value="employeeManageDao")
public class StaffManagementDaoImp implements StaffManagementDao {
	@Autowired
	private StaffManagementRepositoey employeeManageRepositoey;

	public List<StaffManagement> queryEmployeeManage(String status,Pageable pageable) {
		// TODO Auto-generated method stub
		List<StaffManagement> list = new ArrayList<StaffManagement>();
		list = employeeManageRepositoey.findByStatus(status,pageable);
		return list;
	}
	
	public List<StaffManagement> queryDetailed(int id) {
		// TODO Auto-generated method stub
		List<StaffManagement> list = new ArrayList<StaffManagement>();
		list = employeeManageRepositoey.queryDetailed(id);
		return list;
	}
	
	public void insertEmployee(StaffManagement em) {
		// TODO Auto-generated method stub
		employeeManageRepositoey.save(em);
	}
	
	public void updateEmployee(StaffManagement em) {
		// TODO Auto-generated method stub
		employeeManageRepositoey.saveAndFlush(em);
	}
	public int countEmployee(){
		return (int) employeeManageRepositoey.count();
	}

	public StaffManagement queryNumber(String number) {
		// TODO Auto-generated method stub
		return employeeManageRepositoey.findByNumber(number);
	}

	public int countEmployee(String stasus) {
		// TODO Auto-generated method stub
		return employeeManageRepositoey.findByStatus(stasus).size();
	}



}
